<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/InnerSystemTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="head-title">
        <title>View Sale Inquiry | Merlion's ERP System</title>
    </ui:define>
    
    <ui:define name="content">
        <h:form prependId="false">
        <p:dataTable var="saleInquiry" value="#{saleInquiryDataTableBean.saleInquiry}" 
                     dynamic="true" paginator="true" rows="5" emptyMessage="No Sale Inquiry" selection="#{saleInquiryDataTableBean.selectedSaleInquiry}" onRowSelectUpdate="display"> 
            <p:column selectionMode="single"/>
            <p:column sortBy="#{saleInquiry.id}" filterBy="#{saleInquiry.id}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Sale Inquiry ID" /> 
                        </f:facet> 
                        <h:outputText value="#{saleInquiry.id}" /> 
                    </p:column> 
 
                    <p:column sortBy="#{saleInquiry.saleInquiryDate}" filterBy="#{saleInquiry.saleInquiryDate}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Date" /> 
                        </f:facet> 
                        <h:outputText value="#{saleInquiry.saleInquiryDate}" /> 
                    </p:column> 
                   
                    <p:column sortBy="#{saleInquiry.saleLead.registrationNumber}" filterBy="#{saleInquiry.saleLead.registrationNumber}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Registration Number" /> 
                        </f:facet> 
                        <h:outputText value="#{saleInquiry.saleLead.registrationNumber}" /> 
                    </p:column>
                     
                    <p:column sortBy="#{saleInquiry.saleLead.saleLeadName}" filterBy="#{saleInquiry.saleLead.saleLeadName}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Company Name" /> 
                        </f:facet> 
                        <h:outputText value="#{saleInquiry.saleLead.saleLeadName}" /> 
                    </p:column>
            
                    <f:facet name="footer">                    
                        <p:commandButton value="View" image="ui-icon ui-icon-search" update="display1 display2" oncomplete="inquiryViewDialog.show()">
                            
                        </p:commandButton>  

                        <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{saleInquiryDataTableBean.editSaleInquiry}">
                            <f:attribute name="selectedSaleInquiry" value="#{saleInquiry}"/>
                        </p:commandButton>  

                        <p:commandButton value="Delete" image="ui-icon ui-icon-close" update="display3 display4" oncomplete="inquiryDeleteDialog.show()">

                        </p:commandButton>

                        <p:commandButton value="Convert" actionListener="#{saleInquiryDataTableBean.createSaleQuotation}">
                            <f:attribute name="selectedSaleInquiry" value="#{saleInquiry}"/>
                        </p:commandButton>
                    </f:facet>
            
        </p:dataTable>
            
            <p:dialog header="Sale Inquiry Detail" widgetVar="inquiryViewDialog" width="400" height="400" resizable="true" showEffect="explode" hideEffect="explode">
                <h:panelGrid id="display1" columns="2" cellpadding="4">
                    
                    <h:outputText value="Sale Inquiry ID:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.id}"/>
                    
                    <h:outputText value="Date:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleInquiryDate}"/>
                    
                    <h:outputText value="Sale Lead ID:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleLead.saleLeadId}"/>
                    
                    <h:outputText value="Sale Lead Name:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleLead.saleLeadName}"/>
                
                </h:panelGrid>
                
                <p:dataTable var="lineItem" value="#{saleInquiryDataTableBean.selectedSaleInquiry.lineItems}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type" id="display2">
                    <p:column sortBy="#{lineItem.product.productType}">
                        <f:facet name="header">
                            <h:outputText value="Product Type"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.product.productType}"/>
                    </p:column>
                        
                    <p:column sortBy="#{lineItem.lineItemQuantity}">
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.lineItemQuantity}"/>
                    </p:column>
                    
                    <p:column sortBy="#{lineItem.product.productPrice}">
                        <f:facet name="header">
                            <h:outputText value="Price"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.product.productPrice}"/>
                    </p:column>
                 </p:dataTable>
   
            </p:dialog>
            
            <p:dialog header="Sale Inquiry Detail" widgetVar="inquiryDeleteDialog" width="400" height="400" resizable="false" showEffect="explode" hideEffect="explode">
                <h:panelGrid id="display3" columns="2" cellpadding="4">
                    
                    <h:outputText value="Sale Inquiry ID:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.id}"/>
                    
                    <h:outputText value="Date:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleInquiryDate}"/>
                    
                    <h:outputText value="Sale Lead ID:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleLead.saleLeadId}"/>
                    
                    <h:outputText value="Sale Lead Name:"/>
                    <h:outputText value="#{saleInquiryDataTableBean.selectedSaleInquiry.saleLead.saleLeadName}"/>
                    
                    
                
                </h:panelGrid>
                
                <p:dataTable var="lineItem" value="#{saleInquiryDataTableBean.selectedSaleInquiry.lineItems}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type" id="display4">
                        <p:column sortBy="#{lineItem.product.productType}">
                            <f:facet name="header">
                                <h:outputText value="Product Type"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productType}"/>
                        </p:column>

                        <p:column sortBy="#{lineItem.lineItemQuantity}">
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.lineItemQuantity}"/>
                        </p:column>

                        <p:column sortBy="#{lineItem.product.productPrice}">
                            <f:facet name="header">
                                <h:outputText value="Price"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.product.productPrice}"/>
                        </p:column>
                 </p:dataTable>
                
                <p:spacer height="35"/>
                
                 <p:commandButton value="Confirm Delete" actionListener="#{saleInquiryDataTableBean.deleteSaleInquiry}" oncomplete="inquiryDeleteDialog.hide()">
                        <f:attribute name="selectedSaleInquiry" value="#{saleInquiry}"/>
                 </p:commandButton>
                <p:commandButton value="Cancel" onclick="inquiryDeleteDialog.hide()"/>
                <p:messages />
   
            </p:dialog>
            
        </h:form>
    </ui:define>

</ui:composition>